package com.jiyun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.mapper.AnnouncementMapper;
import com.jiyun.pojo.Announcement;
import com.jiyun.service.AnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.AccessType;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Announcement> implements AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;
    @Override
    public List<Announcement> findAll() {
        QueryWrapper<Announcement> queryWrapper = new QueryWrapper<>();
        // 使用orderByDesc方法指定按照upload_time字段进行降序（倒序）排列
        queryWrapper.orderByDesc("upload_time");
        List<Announcement> list = announcementMapper.selectList(queryWrapper);
        return list;
    }
}
